<?
	require "view/objects/news.class.php";
	$news 		= new news();
	$menuleftHD		= $news->GetLeftMenuHD();
	$menuleftDC		= $news->GetLeftMenuDC("");
	$menuleftmovie	= $news->GetLeftMenuMovie();
	$hotnews		= $news->GetListNewsHot();
	//$p			= intval($m[2]);
	global $pub,$sql;
		$detail		= $news->GetProductDetail1($m[1]);
		$action		= PATH_HTTP."Lien-he-bao-gia/".$m[1]."/";	
		$bill='';
		$i=1;
		
		if($_REQUEST['re_send']!=""){
			$sl[$i]		= $_REQUEST['txtsl_'.$i];
			$bill		= "NV-".date("YHs");
			$price		= $rows['pro_price']*$sl[$i];
			$fullname	= $_REQUEST['re_name'];
			$email		= $_REQUEST['re_email'];
			$address	= $_REQUEST['re_address'];
			$tel		= $_REQUEST['re_tel'];
			$dateadd	= date("Y/m/d H:i");
			$subject	= $_REQUEST['re_title'];
			$content	= addslashes($_REQUEST['re_content']);
				
			$mquery = $sql->query('INSERT INTO orders (bill, fullname, email, address, tel, note, pro_id,pro_title, pro_quantity, pro_totalmoney, dateadd, status) 
						VALUES ("'.$bill.'","'.$fullname.'", "'.$email.'", "'.$address.'", "'.$tel.'","'.$content.'", "'.$rows['pro_id'].'", "'.$rows['pro_title'].'", "'.$sl[$i].'", "'.$price.'", "'.date("Y/m/d").'", "2")');	
				if($result>0){
				//Send mail
					$to 		= "toanvu2711@gmail.com";
					$from 		= $email;
					$title 		= $subject;	
						
					$Headers="From:".$from."\n";
					$Headers.="Reply-To:".$from."\n";			
					$Headers.="Content-Type: text/html; charset=\"UTF-8\"; boundary=\"MIME_BOUNDRY\"\n";
					$Headers.="X-Sender:".$title."\n";
					$Headers.="X-Mailer: PHP5\n"; 
					$Headers.="X-Priority: 3\n"; 
					$Headers.="Return-Path:".$from."\n";
					$Subject = $subject;
						
					$content .= "============== CONTACT FROM =====================<br />
								Xin cảm ơn bạn đã liên hệ với chúng tôi<br/>
								BÁO GIÁ SẢN PHẨM<br/>
								Tên sản phẩm : ".$rows['pro_title']." :<br/>
								Số lượng : ".$sl[$i]."<br/>
								Giá : ".$price."<br/>
								Click vào link nếu bạn muốn đặt hàng<br/>
								<a href='".WEBSITE."'>".WEBSITE."</a><br>				
								=================== CONTENT ========================<br />
								".addslashes($content)."							
								===========================================================<br />";
					
					$content.= date('d-m-y H:i')."<br />";
					
				}
				if($mquery!=""){
					$str = 1;
				}
				else{
					$str = 0;
				}
				if($str=="1"){
				echo $pub->direct(PATH_HTTP,"Chúc mừng bạn gửi mail thành công");							
					
				return mail($to,$Subject,$content,$Headers);							
			}else{
				echo $pub->direct(PATH_HTTP."Lien-he-bao-gia/".$m[1]."/","Đặt hàng không thành công");							
				
				return mail($to,$Subject,$content,$Headers);							
			}
		
		}
		
?>